/******************************************************************************
* @file   main
* @brief  演示VirtLCD的使用方法
*         引用头文件:virtlcd.h
*         引用动态库:virtlcd.lib
* @author 蒋晓岗<kerndev@foxmail.com>
*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include "virtlcd.h"
#include "lcd.h"
#include "lvgl.h"
#include "lv_demos.h"

#pragma comment(lib,"virtlcd.lib")

/*
 * @brief 
 */
#define LCD_SCALE  1   //放大2倍，像素点看得更清楚

/* private functions */

/* import functions */
extern void lv_port_disp_init(void);
extern void lv_port_indev_init(void);

void tick_task(void* param)
{
    while (1)
    {
//        lv_tick_inc(15);//根据处理器仿真具体时间
        lv_tick_inc(2);//根据处理器仿真具体时间
        Sleep(1);
    }
}

/*
 * @brief 
 * @param 
 * @retval 
 */
void main(void)
{
    HANDLE *pWinThread;

	lcd_init(); 
	if (VirtLCD_Init(lcd_get_x_size(), lcd_get_y_size(), lcd_get_bpp(), LCD_SCALE)==0)
	{
		LV_LOG_USER("init virtual lcd fail!\n");
		system("pause");
		return;
	}
	lcd_set_frame_buff(VirtLCD_GetFrameBuffer());
	LV_LOG_USER("Init virtual lcd success!\n");
	lcd_clear();
    
    lv_init();
    lv_port_disp_init();
    lv_port_indev_init();

    pWinThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)tick_task,NULL,0,NULL);
    if (SetThreadPriority(pWinThread, THREAD_PRIORITY_HIGHEST))
    {
        LV_LOG_USER("config the most priority of the task lv_tick_inc!\n");
    }

//    lv_demo_music();
    volumio_music();
//    lv_volumio_test();
	while (1)
	{
		lv_task_handler();        
        Sleep(1);
	}
}



